<!-- Copyright and License Information v1
    Albatross Shell Framework
    http://AlbatrossShell.codeplex.com/
    Copyright Rushui Guan 2013-2014.  All rights reserved.
    Distributed under the terms of the Microsoft Public License (Ms-PL). 
    The license is available online http://AlbatrossShell.codeplex.com/license 
-->



<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Albatross.WPF.Common.Controls"
	xmlns:common="clr-namespace:Albatross.WPF.Common.Views"
	xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase">

	<common:BooleanVisibilityConverter x:Key="bool2visibility"/>
	<common:BooleanVisibilityConverter x:Key="bool2visibility reversed" Reversed="True" CollapseOrHidden="Hidden"/>

	<Style TargetType="{x:Type local:AlbatrossDockPanel}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:AlbatrossDockPanel}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" Name="PART_LeftSection"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="Auto" Name="PART_RightSection"/>
						</Grid.ColumnDefinitions>

						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" Name="PART_TopSection"/>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="*"/>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto" Name="PART_BottomSection"/>
						</Grid.RowDefinitions>

						<GridSplitter Name="PART_LeftSplitter" Background="DarkGray" Grid.Column="1" Grid.RowSpan="5" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="5" ShowsPreview="True" Visibility="{TemplateBinding DockLeft, Converter={StaticResource bool2visibility}}" />
						<GridSplitter Name="PART_RightSplitter" Background="DarkGray" Grid.Column="3" Grid.RowSpan="5" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="5" ShowsPreview="True" Visibility="{TemplateBinding DockRight, Converter={StaticResource bool2visibility}}" />
						<GridSplitter Name="PART_TopSplitter" Background="DarkGray" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="5" ShowsPreview="True" Visibility="{TemplateBinding DockTop, Converter={StaticResource bool2visibility}}" />
						<GridSplitter Name="PART_BottomSplitter" Background="DarkGray" Grid.Column="2" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="5" ShowsPreview="True" Visibility="{TemplateBinding DockBottom, Converter={StaticResource bool2visibility}}" />

						<Grid Grid.RowSpan="5" Grid.Column="0" Visibility="{TemplateBinding DockLeft, Converter={StaticResource bool2visibility}}" >
							<ContentPresenter Name="PART_LeftCollapsedBar" HorizontalAlignment="Right" DockPanel.Dock="Right" Visibility="{TemplateBinding IsLeftExpanded, Converter={StaticResource bool2visibility reversed}}" ContentTemplate="{TemplateBinding LeftCollapseBarTemplate}">
								<ContentPresenter.Content>
									<Border Background="{TemplateBinding LeftHeaderBackground}" Padding="{TemplateBinding LeftHeaderPadding}" BorderBrush="Silver" BorderThickness="1 1 0 1">
										<DockPanel>
											<ToggleButton DockPanel.Dock="Top" IsChecked="{Binding IsLeftExpanded, RelativeSource={RelativeSource TemplatedParent}}">
												<ToggleButton.Template>
													<ControlTemplate>
														<Border BorderThickness="0">
															<Image Cursor="Hand" Width="16" Margin="0" VerticalAlignment="Stretch" Source="/Albatross.WPF.Common;component/Images/Right.png"/>
														</Border>
													</ControlTemplate>
												</ToggleButton.Template>
											</ToggleButton>
											<TextBlock Text="{TemplateBinding LeftHeader}" TextAlignment="Center">
												<TextBlock.LayoutTransform>
													<RotateTransform Angle="-90"/>
												</TextBlock.LayoutTransform>
											</TextBlock>
										</DockPanel>
									</Border>
								</ContentPresenter.Content>
							</ContentPresenter>
							<DockPanel LastChildFill="True" Width="{Binding LeftSectionWidth, RelativeSource={RelativeSource TemplatedParent}}">
								<ContentPresenter Name="PART_LeftHeader" ContentSource="Left" DockPanel.Dock="Top" Visibility="{TemplateBinding IsLeftExpanded, Converter={StaticResource bool2visibility}}" ContentTemplate="{TemplateBinding LeftHeaderTemplate}">
									<ContentPresenter.Content>
										<Border Background="{TemplateBinding LeftHeaderBackground}" Padding="{TemplateBinding LeftHeaderPadding}" BorderBrush="Silver" BorderThickness="1 1 0 1">
											<DockPanel>
												<ToggleButton IsChecked="{Binding IsLeftExpanded, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Top" DockPanel.Dock="Right">
													<ToggleButton.Template>
														<ControlTemplate>
															<Border BorderThickness="0">
																<Image Cursor="Hand" Width="16" Margin="0" VerticalAlignment="Top" Source="/Albatross.WPF.Common;component/Images/Left.png" />
															</Border>
														</ControlTemplate>
													</ToggleButton.Template>
												</ToggleButton>
												<TextBlock Text="{TemplateBinding LeftHeader}" />
											</DockPanel>
										</Border>
									</ContentPresenter.Content>
								</ContentPresenter>
								<Border BorderBrush="Silver" BorderThickness="1 0 0 1" Visibility="{TemplateBinding IsLeftExpanded, Converter={StaticResource bool2visibility}}">
									<ContentPresenter ContentSource="Left" />
								</Border>
							</DockPanel>
						</Grid>

						<Grid Grid.RowSpan="5" Grid.Column="4" Visibility="{TemplateBinding DockRight, Converter={StaticResource bool2visibility}}">
							<ContentPresenter Name="PART_RightCollapsedBar" HorizontalAlignment="Right" DockPanel.Dock="Right" Visibility="{TemplateBinding IsRightExpanded, Converter={StaticResource bool2visibility reversed}}" ContentTemplate="{TemplateBinding RightCollapseBarTemplate}">
								<ContentPresenter.Content>
									<Border Background="{TemplateBinding RightHeaderBackground}" Padding="{TemplateBinding RightHeaderPadding}" BorderBrush="Silver" BorderThickness="0 1 1 1">
										<DockPanel>
											<ToggleButton DockPanel.Dock="Top" IsChecked="{Binding IsRightExpanded, RelativeSource={RelativeSource TemplatedParent}}">
												<ToggleButton.Template>
													<ControlTemplate>
														<Border BorderThickness="0">
															<Image Cursor="Hand" Width="16" Margin="0" VerticalAlignment="Stretch" Source="/Albatross.WPF.Common;component/Images/Left.png"/>
														</Border>
													</ControlTemplate>
												</ToggleButton.Template>
											</ToggleButton>
											<TextBlock Text="{TemplateBinding RightHeader}" TextAlignment="Center">
												<TextBlock.LayoutTransform>
													<RotateTransform Angle="-90"/>
												</TextBlock.LayoutTransform>
											</TextBlock>
										</DockPanel>
									</Border>
								</ContentPresenter.Content>
							</ContentPresenter>
							<DockPanel LastChildFill="True" Width="{Binding RightSectionWidth, RelativeSource={RelativeSource TemplatedParent}}">
								<ContentPresenter Name="PART_RightHeader" ContentSource="Right" DockPanel.Dock="Top" Visibility="{TemplateBinding IsRightExpanded, Converter={StaticResource bool2visibility}}" ContentTemplate="{TemplateBinding RightHeaderTemplate}">
									<ContentPresenter.Content>
										<Border Background="{TemplateBinding RightHeaderBackground}" Padding="{TemplateBinding RightHeaderPadding}" BorderBrush="Silver" BorderThickness="0 1 1 1">
											<DockPanel>
												<ToggleButton IsChecked="{Binding IsRightExpanded, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Top" DockPanel.Dock="Right">
													<ToggleButton.Template>
														<ControlTemplate>
															<Border BorderThickness="0">
																<Image Cursor="Hand" Width="16" Margin="0" VerticalAlignment="Top" Source="/Albatross.WPF.Common;component/Images/Right.png" />
															</Border>
														</ControlTemplate>
													</ToggleButton.Template>
												</ToggleButton>
												<TextBlock Text="{TemplateBinding RightHeader}" />
											</DockPanel>
										</Border>
									</ContentPresenter.Content>
								</ContentPresenter>
								<Border BorderBrush="Silver" BorderThickness="0 0 1 1" Visibility="{TemplateBinding IsRightExpanded, Converter={StaticResource bool2visibility}}">
									<ContentPresenter ContentSource="Right" />
								</Border>
							</DockPanel>
						</Grid>

						<DockPanel Grid.Column="2" LastChildFill="True" Visibility="{TemplateBinding DockTop, Converter={StaticResource bool2visibility}}">
							<ContentPresenter Name="PART_TopHeader" ContentSource="Top" DockPanel.Dock="Top" ContentTemplate="{TemplateBinding TopHeaderTemplate}">
								<ContentPresenter.Content>
									<Border Background="{TemplateBinding TopHeaderBackground}" Padding="{TemplateBinding TopHeaderPadding}" BorderBrush="Silver" BorderThickness="0 1 0 1">
										<DockPanel>
											<ToggleButton IsChecked="{Binding IsTopExpanded, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Right">
												<ToggleButton.Template>
													<ControlTemplate>
														<Border BorderThickness="0">
															<Image Cursor="Hand" Width="16" Margin="0">
																<Image.Style>
																	<Style TargetType="Image">
																		<Setter Property="Source" Value="/Albatross.WPF.Common;component/Images/Down.png"/>
																		<Style.Triggers>
																			<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
																				<Setter Property="Source" Value="/Albatross.WPF.Common;component/Images/Up.png"/>
																			</DataTrigger>
																		</Style.Triggers>
																	</Style>
																</Image.Style>
															</Image>
														</Border>
													</ControlTemplate>
												</ToggleButton.Template>
											</ToggleButton>
											<TextBlock Text="{TemplateBinding TopHeader}" />
										</DockPanel>
									</Border>
								</ContentPresenter.Content>
							</ContentPresenter>
							<ContentPresenter ContentSource="Top" Visibility="{TemplateBinding IsTopExpanded, Converter={StaticResource bool2visibility}}" Height="{Binding TopSectionHeight, RelativeSource={RelativeSource TemplatedParent}}" />
						</DockPanel>

						<DockPanel Grid.Column="2" Grid.Row="4" LastChildFill="True" Visibility="{TemplateBinding DockBottom, Converter={StaticResource bool2visibility}}">
							<ContentPresenter Name="PART_BottomHeader" ContentSource="Bottom" DockPanel.Dock="Top" ContentTemplate="{TemplateBinding BottomHeaderTemplate}">
								<ContentPresenter.Content>
									<Border Background="{TemplateBinding BottomHeaderBackground}" Padding="{TemplateBinding BottomHeaderPadding}" BorderBrush="Silver">
										<DockPanel>
											<ToggleButton IsChecked="{Binding IsBottomExpanded, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Right">
												<ToggleButton.Template>
													<ControlTemplate>
														<Border BorderThickness="0">
															<Image Cursor="Hand" Width="16" Margin="0">
																<Image.Style>
																	<Style TargetType="Image">
																		<Setter Property="Source" Value="/Albatross.WPF.Common;component/Images/Up.png"/>
																		<Style.Triggers>
																			<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
																				<Setter Property="Source" Value="/Albatross.WPF.Common;component/Images/Down.png"/>
																			</DataTrigger>
																		</Style.Triggers>
																	</Style>
																</Image.Style>
															</Image>
														</Border>
													</ControlTemplate>
												</ToggleButton.Template>
											</ToggleButton>
											<TextBlock Text="{TemplateBinding BottomHeader}" />
										</DockPanel>
									</Border>
								</ContentPresenter.Content>
							</ContentPresenter>
							<Border BorderBrush="Silver" BorderThickness="0 1 0 1" Visibility="{TemplateBinding IsBottomExpanded, Converter={StaticResource bool2visibility}}">
								<ContentPresenter ContentSource="Bottom" Height="{Binding BottomSectionHeight, RelativeSource={RelativeSource TemplatedParent}}" />
							</Border>
						</DockPanel>

						<ContentPresenter Grid.Column="2" Grid.Row="2" />
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
